package physics.component;

import java.awt.Graphics2D;
import physics.Simulation;
import ui.Drawable;


/**
 * A physical object that can be updated and drawn into a simulation.
 *
 * @author Kevin Gao, Connor Gordon
 *
 */
public abstract class PhysicalObject implements Drawable {

    /**
     * Method responsible for painting the object onto the canvas. Left
     * unimplemented.
     *
     * @param pen Graphics2D object for drawing on canvas.
     */
    @Override
    public final void paint (final Graphics2D pen) {
        determineColor(pen);
        drawShape(pen);
    }

    /**
     * Updates the object within the context of the simulation.
     *
     * @param canvas The canvas that objects should be drawn on
     * @param dt Change in simulation time
     */
    public abstract void update (Simulation canvas, double dt);

    /**
     * This method will determine what color the object should be drawn as.
     *
     * @param pen Graphics2D object for drawing on canvas.
     */
    protected abstract void determineColor (final Graphics2D pen);

    /**
     * This method will draw the shape for the given object.
     *
     * @param pen Graphics2D object for drawing on canvas.
     */
    protected abstract void drawShape (final Graphics2D pen);

}
